# coding=utf-8

from app.dao.api.user import get_user_by_token
from app.dao.api.user_gift import get_cash
from app.dao.api.match import *
from app.result.api.match import *


def enterroom_service(token) :
    user = get_user_by_token(token)
    if user is None :
        return show_result(ShowCode.ERROR)

    user_cash = get_cash(token)
    if user_cash is None:
        return show_result(ShowCode.ERROR)

    result = enter_room(token, user, user_cash)
    if not result:
        return show_result(ShowCode.ERROR)
    return show_result(ShowCode.SUCCESS, result)
